﻿namespace AutoMock.Scenarios.Customer
{
    public class CustomerUpdater
    {
        private readonly ICustomerDataProvider _customerData;
        private readonly ILogWriter _logWriter;
        private readonly IWriter[] _writers;
        private readonly IMailSender _mailSender;

        public CustomerUpdater(
            ICustomerDataProvider customerData,
            IMailSender mailSender,
            ILogWriter logWriter,
            IWriter[] writers)
        {
            _customerData = customerData;
            _mailSender = mailSender;
            _logWriter = logWriter;
            _writers = writers;
        }

        public void UpdateCustomerName(int customerId, string name, string email)
        {
            var customer = _customerData.GetCustomer(1);

            customer.Name = name;

            _customerData.UpdateCustomer(customer);

            _logWriter.Write(string.Format("Customer {0} has been updated", name));

            _mailSender.SendMail(email, string.Format("Customer {0} has been updated", name));
        }
    }
}